home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / tcclib.zip / DEMO4.C < prev    next >
Text File  |  1989-02-11  |  2KB  |  80 lines

  1. /*****************************************************************
  2.                            GetFieldDemo
  3. ******************************************************************/
  4. #include "tcclib.h"
  5. #include <conio.h>
  6.  
  7. char First[20] = {"George"},
  8.      Last[20] = {"Cross"},
  9.      City[20] = {"Greenwood"},
  10.      Address1[40] = {"15 Faculty Lane"},
  11.      Address2[40] = {" "},
  12.      State[3] = {"SC"},
  13.      AreaCode[4] = {"999"},
  14.      Phone[15] = {"123-4567"};
  15. long ZIP = 0;
  16. int  Fee = 25;
  17. int  PaidFlag = 0;
  18. int  AmountDue = 25;
  19.  
  20. FieldStruc SampleFields[] = {
  21.     20, 19,  3, F_INT,  (char *)&AmountDue, 0, 0,
  22.     20,  7, 18, F_PTR,           First    , 1, 0,
  23.     20,  9, 28, F_PTR,           Address1 , 1, 0,
  24.     20, 10, 28, F_PTR,           Address2 , 1, 0,
  25.     20, 11, 18, F_PTR,           City     , 1, 0,
  26.     21, 13,  3, F_PTR,           AreaCode , 1, 0,
  27.     20, 15,  3, F_INT,  (char *)&Fee      , 1, 0,
  28.     44, 15,  1, F_BLN,  (char *)&PaidFlag , 1, 0,
  29.     48, 11,  2, F_PTR,           State    , 1, 0,
  30.     53,  7, 18, F_PTR,           Last     , 1, 0,
  31.     26, 13, 14, F_PTR,           Phone    , 1, 0,
  32.     59, 11,  5, F_LNG0, (char *)&ZIP      , 1, 0
  33. };
  34.  
  35. #define NUMFIELDS (sizeof(SampleFields)/sizeof(FieldStruc))
  36.  
  37. int ChHandDemo( int ch )
  38. /*  This function handles keystrokes not handled by "GetAllFields"
  39.  
  40.     Note:  This demo function serves no truly useful purpose, other than
  41.            to show you haw to write your own function.
  42. */
  43. {
  44.     if ( ch == ALT_F1 ) {
  45.         ExplodeBox( 25, 22, 55, 24 );
  46.         Center( 23, "Special Key Handler" );
  47.         GComm();
  48.     }
  49.     else if ( ch == ESC )
  50.         return( -1 );
  51.     return( 1 );
  52. }
  53.  
  54. void UpdateDemo( void )
  55. {
  56.     if ( !PaidFlag )
  57.         AmountDue = Fee;
  58.     else
  59.         AmountDue = 0;
  60.     PutField( &SampleFields[0] );
  61. }
  62.  
  63. void GetFieldDemo()
  64. {
  65.     clrscr();
  66.     ExplodeBox( 5, 5, 75, 21 );
  67.     AtSay(  7,  7, "First Name : " );
  68.     AtSay(  7,  9, "Address    : " );
  69.     AtSay(  7, 11, "City       : " );
  70.     AtSay(  7, 13, "Phone      : (   )" );
  71.     AtSay(  7, 15, "Fee        : " );
  72.     AtSay(  7, 19, "Amount Due : " );
  73.     AtSay( 37, 15, "Paid : " );
  74.     AtSay( 40, 11, "State : " );
  75.     AtSay( 54, 11, "ZIP : " );
  76.     AtSay( 40,  7, "Last Name : " );
  77.     Center( 25, "ESC=Quit              ALT-F1=Explode Box" );
  78.     GetAllFields( SampleFields, NUMFIELDS, ChHandDemo, UpdateDemo );
  79. }
  80.